using System.ComponentModel.DataAnnotations;
using MediatR;
using Process.DAL;

namespace Process.Api.Application.Command.BOM
{
    public class UpdateBomCommand : IRequest<ApiResult<int>>
    {
        /// <summary>
        /// BOM ID
        /// </summary>
        [Required(ErrorMessage = "BOM ID不能为空")]
        public int Id { get; set; }

        /// <summary>
        /// BOM编号
        /// </summary>
        [Required(ErrorMessage = "BOM编号不能为空")]
        [StringLength(50, ErrorMessage = "BOM编号长度不能超过50个字符")]
        public string BOMCode { get; set; }

        /// <summary>
        /// BOM名称
        /// </summary>
        [Required(ErrorMessage = "BOM名称不能为空")]
        [StringLength(100, ErrorMessage = "BOM名称长度不能超过100个字符")]
        public string BOMTitle { get; set; }

        /// <summary>
        /// 关联产品（物品）ID，可选
        /// </summary>
        public int? ProductGoodsId { get; set; }

        /// <summary>
        /// 产品编号（冗余展示）
        /// </summary>
        [StringLength(50, ErrorMessage = "产品编号长度不能超过50个字符")]
        public string ProductsCode { get; set; }

        /// <summary>
        /// 产品名称（冗余展示）
        /// </summary>
        [StringLength(100, ErrorMessage = "产品名称长度不能超过100个字符")]
        public string ProductsName { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        [StringLength(100, ErrorMessage = "规格型号长度不能超过100个字符")]
        public string ProductsModel { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        [StringLength(20, ErrorMessage = "单位长度不能超过20个字符")]
        public string ProductsUnit { get; set; }

        /// <summary>
        /// 品牌
        /// </summary>
        [StringLength(50, ErrorMessage = "品牌长度不能超过50个字符")]
        public string Brand { get; set; }

        /// <summary>
        /// 是否默认版本
        /// </summary>
        public bool Status { get; set; }

        /// <summary>
        /// 版本号
        /// </summary>
        [StringLength(20, ErrorMessage = "版本号长度不能超过20个字符")]
        public string Version { get; set; }

        /// <summary>
        /// 日产量
        /// </summary>
        [Range(0, int.MaxValue, ErrorMessage = "日产量必须大于等于0")]
        public int Output { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [StringLength(500, ErrorMessage = "备注长度不能超过500个字符")]
        public string Desc { get; set; }

        /// <summary>
        /// 配件列表 - 一对多关系
        /// </summary>
        public List<BomGoodsRelationDto> GoodsRelations { get; set; } = new List<BomGoodsRelationDto>();

        /// <summary>
        /// 工艺流程列表 - 一对多关系
        /// </summary>
        public List<BomFlowRelationDto> FlowRelations { get; set; } = new List<BomFlowRelationDto>();

        /// <summary>
        /// 是否保留原有关系（当为true时，如果关系数组为空则保留原有关系）
        /// </summary>
        public bool KeepExistingRelations { get; set; } = false;
    }
}
